package com.demo01.demo.Repository;

import com.demo01.demo.entity.Milktea;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface MilkteaRepository extends JpaRepository<Milktea,String> {
    public Optional<Milktea> findByName(String name);
    @Query(value = "select * from  milktea where if(?1!='',id= ?1,true) and if(?2!='', name like ?2,true) and if(?3!='', des = ?3,true) and if(?4!='',price= ?4,true)  and if(?5!='', type= ?5,true) and if(?6!='',typename= ?6,true) ",nativeQuery = true)
    public Page<Milktea> find(String sql1, String sql2, String sql3, String sql4, String sql5, String sql6, Pageable pageable);
    @Query(value = "select * from  milktea where if(?1!='',id= ?1,true) and if(?2!='', name like ?2,true) and if(?3!='', des = ?3,true) and if(?4!='',price= ?4,true)  and if(?5!='', type= ?5,true) and if(?6!='',typename= ?6,true) ",nativeQuery = true)
    public List<Milktea> searchall(String sql1, String sql2, String sql3, String sql4, String sql5, String sql6);
}
